package com.zhb.lkd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhb.lkd.pojos.entity.Order;
import com.zhb.lkd.mapper.OrderMapper;
import com.zhb.lkd.service.IOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author haibin
 * @since 2024-08-18
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {

    @Override
    public Long orderCount(LocalDateTime start, LocalDateTime end) {
        //1.检查参数是否正常
        if (start == null || end == null) {
            return 0L;
        }
        //2.查询数据
        Long count = lambdaQuery().between(Order::getCreateTime, start, end).count();
        return count;
    }

    /**
     * 销售额统计
     * @param start
     * @param end
     * @return
     */
    @Override
    public Long orderAmount(LocalDateTime start, LocalDateTime end) {
        //1.检查参数是否正常
        if (start == null || end == null) {
            return 0L;
        }
        //2.查询数据
        Long Amount=getBaseMapper().selectOrderAmount(start, end);
        return Amount;
    }
}
